#ifndef RPGSPRITE_H
#define RPGSPRITE_H

#include <PA9.h>

#include "rpgspritepal.h"

#define fix(x)  ((x) << 8)
#define norm(x) ((x) >> 8)

class RpgSprite
{
public:
    RpgSprite(u8 screen, u8 id, void *data, RpgSpritePal *palette);
    void create();
    void updatePosition();

    void setPosition(s32 x, s32 y) { m_x = fix(x); m_y = fix(y); }
    void setPositionX(s32 x) { m_x = fix(x); }
    void setPositionY(s32 y) { m_y = fix(y); }
    void setScrollPositionX(s32 scrollX) { m_scrollX = fix(scrollX); }
    void setScrollPositionXf(s32 scrollXf) { m_scrollX = scrollXf; }
    void setScrollPositionY(s32 scrollY) { m_scrollY = fix(scrollY); }
    void setScrollPositionYf(s32 scrollYf) { m_scrollY = scrollYf; }

    s32 x() { return norm(m_x); }
    s32 xf() { return m_x; }
    s32 y() { return norm(m_y); }
    s32 yf() { return m_y; }
    s32 scrollX() { return norm(m_scrollX); }
    s32 scrollXf() { return m_scrollX; }
    s32 scrollY() { return norm(m_scrollY); }
    s32 scrollYf() { return m_scrollY; }
    u8 screen() { return m_screen; }
    u8 id() { return m_id; }

protected:
    u8 colourMode() { return m_colourMode; }
    RpgSpritePal *palette() { return m_palette; }
    void *data() { return m_data; }

private:
    s32 m_x;
    s32 m_y;
    s32 m_scrollX;
    s32 m_scrollY;
    u8 m_screen;
    u8 m_id;
    u8 m_colourMode;
    RpgSpritePal *m_palette;
    void *m_data;

};

#endif // RPGSPRITE_H
